June 14, 2019
v3 Receiving SMS/MMS messages
Description:
Receive SMS/MMS messages on the numbers you rent from MultiTEL
Prerequisites:
You need to have a SMS enabled number in your account. For the purposes of this how-to document, this will be 15672058715.
This will only work via POST method (no GET) (If you need help renting a phone number, please visit this link. The first 30 seconds of that video should be self-explanatory.)
What do you need to do first?:
Edit the number and set up the SMS destination: 1. Go to https://multitel.net/numbers/inventory ( This is located in the "Numbers" section on left hand side , called "My Numbers")
2. Edit the phone number:
3. Go in the SMS/MMS tab and edit the settings:
This should be enough for MultiTEL to start sending you SMS/MMS messages via HTTP(s) POST.
Parameters we will send:
from
to
text
mediaurls
Sample NGREP capture:
For MMS:
(message contains just an image)
T 104.X.Y.Z:39452 -> 139.X.Y.Z:80 [AP]
POST /inbound.php HTTP/1.1.
Host: crm-test.multitel.net.
Accept: */*.
Content-Type: application/x-www-form-urlencoded.
Content-Length: 118.
.
from=15862040XYZ&to=15672058715&mediaurls%5B0%5D=https%3A%2F%2Fs3.amazonaws.com%2Fxbyhmms02%2FmLyrS05nj5tp0gDi9XYZ.jpg
For MMS:
(message contains both text and an image)
T 104.X.Y.X:55388 -> 139.X.Y.Z:80 [AP]
POST /handler.php HTTP/1.1.
Host: crm-test.multitel.net.
Accept: */*.
Content-Type: application/x-www-form-urlencoded.
Content-Length: 205.
.
from=15862040XYZ&to=15672058715&mediaurls%5B0%5D=https%3A%2F%2Fs3.amazonaws.com%2Fixnhmms02%2FMeXiU6uPfcg201283745.jpg
&mediaurls%5B1%5D=https%3A%2F%2Fs3.amazonaws.com%2Frxytmms02%2Fa4zuc0Jbyuw501234567.txt
(notice that the text of the message - due to it being a MMS message - is also part of the mediaurls array)
For SMS:
(message contains just text)
T 104.X.Y.Z:56292 -> 139.X.Y.Z:80 [AP]
POST /handler.php HTTP/1.1.
Host: crm-test.multitel.net.
Accept: */*.
Content-Type: application/x-www-form-urlencoded.
Content-Length: 45.
.
from=15862040XYZ&to=15672058715&text=hi+there
Sample code for parsing the input and sending it via e-mail (this would be on your server):
<?php
$input = $_POST;
$subject = "New SMS/MMS message from ".$input['from']." to ".$input['to'];
$to = "dearcustomer@mailserver.abc";
$message = "You have received a new message from ".$input['from']."\n";
$message.= "This message has been sent to your phone number, ".$input['to']."\n";
$message.= "Message contents, below:\n\n";
$message.= (!empty($_POST['text']) ? $_POST['text'] : ''); // if MMS , there will be no $_POST['text'] parameter
$message.= "\n\n";
if (!empty($_POST['mediaurls'])) {
foreach ($_POST['mediaurls'] as $url) {
$message.= urldecode($url)."\n";
}
}
echo $message;
$headers = "From: webmaster@mailserver.abc\r\n";
mail($to,$subject,$message,$headers);
?>